package cn.yuan.xiaoyu.wangmodule.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.OnClick;
import cn.yuan.xiaoyu.R;
import cn.yuan.xiaoyu.commonmodule.activity.BaseActivity;
import cn.yuan.xiaoyu.commonmodule.utils.StatusBarCompatUtils;
import cn.yuan.xiaoyu.wangmodule.view.MyInfoCheckSexDialog;
import cn.yuan.xiaoyu.wangmodule.view.multiplepicture.activity.MultiplePicturesActivity;

/**
 * Created by yukuoyuan on 2017/3/2.
 * 这是一个我的个人信息的界面
 */

public class MyInfoActivity extends BaseActivity {
    @Bind(R.id.iv_toolbar_ww_title)
    TextView ivToolbarWwTitle;
    @Bind(R.id.iv_main_me_myinfo_avarar)
    ImageView ivMainMeMyinfoAvarar;
    private int NameType = 1;
    private int IdType = 2;
    private int SignType = 3;
    private Intent intent;

    @Override
    protected void bindPresenter() {

    }

    @Override
    protected void initData(Bundle extras) {

    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_myinfo;
    }

    @Override
    protected void initToolbar() {
        StatusBarCompatUtils.compat(this, Color.BLACK);
        ivToolbarWwTitle.setText("个人信息");
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            if (requestCode == NameType) {

            } else if (requestCode == IdType) {

            } else if (requestCode == SignType) {

            }
            if (resultCode == RESULT_OK) {
                if (requestCode == 0x001) {
                    if (data != null) {
                        ArrayList<String> list = data.getStringArrayListExtra("select_result");
                        Log.d("图片的路径*****", list.get(0));
                        Glide.with(MyInfoActivity.this).load(list.get(0)).centerCrop().into(ivMainMeMyinfoAvarar);
                    }
                }
            }
        }
    }

    @OnClick({R.id.iv_toolbar_ww_back, R.id.rl_main_me_myinfo_avarar, R.id.rl_main_me_myinfo_name, R.id.rl_main_me_myinfo_id, R.id.rl_main_me_myinfo_qrcode, R.id.rl_main_me_myinfo_sex, R.id.rl_main_me_myinfo_address, R.id.rl_main_me_myinfo_sign})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_toolbar_ww_back:
                onBackPressed();
                break;
            case R.id.rl_main_me_myinfo_avarar:
                intent = new Intent(this, MultiplePicturesActivity.class);
                intent.putExtra("number", 1);
                startActivityForResult(intent, 0x001);
                break;
            case R.id.rl_main_me_myinfo_name:
                intent = new Intent(this, UpdataMyInfoActivity.class);
                intent.putExtra("type", NameType);
                startActivityForResult(intent, NameType);
                break;
            case R.id.rl_main_me_myinfo_id:
                intent = new Intent(this, UpdataMyInfoActivity.class);
                intent.putExtra("type", IdType);
                startActivityForResult(intent, IdType);
                break;
            case R.id.rl_main_me_myinfo_qrcode:
                break;
            case R.id.rl_main_me_myinfo_sex:
                MyInfoCheckSexDialog myInfoCheckSexDialog = new MyInfoCheckSexDialog(MyInfoActivity.this);
                myInfoCheckSexDialog.show();
                myInfoCheckSexDialog.setOnButtonClickListener(new MyInfoCheckSexDialog.OnButtonCliickListener() {
                    @Override
                    public void onManClick() {

                    }

                    @Override
                    public void onWomenClick() {

                    }
                });
                break;
            case R.id.rl_main_me_myinfo_address:
                break;
            case R.id.rl_main_me_myinfo_sign:
                intent = new Intent(this, UpdataMyInfoActivity.class);
                intent.putExtra("type", SignType);
                startActivityForResult(intent, SignType);
                break;
        }
    }

}
